package com.balabala.gym_system.mapper;

import com.balabala.gym_system.pojo.entity.Menu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Author:zl
 * Date:2023/5/1 15:27
 */

public interface MenuMapper extends BaseMapper<Menu> {


    /**
     * 根据管理员id查询权限标记集合
     * @param adminId
     * @return
     */
    @Select("SELECT m.perms FROM tb_menu m,tb_admin_role ar,tb_role_menu rm WHERE ar.role_id = rm.role_id AND rm.menu_id = m.id AND ar.admin_id =#{adminId}")
    List<String> findPermsByUserId(Long adminId);

    /**
     * 根据管理id获取菜单id集合
     * @param adminId
     * @return
     */
    @Select("SELECT m.id FROM tb_menu m,tb_admin_role ar,tb_role_menu rm WHERE ar.role_id = rm.role_id AND rm.menu_id = m.id AND ar.admin_id =#{adminId}")
    List<Long> getMenuIdByAdminId(Long adminId);


    @Select("SELECT m.id FROM tb_menu m,tb_role_menu rm WHERE rm.menu_id = m.id AND rm.role_id =#{id}")
    List<Long> getMenuIdByRoleId(Long id);
}
